import javax.swing.*;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Student extends Person implements ActionListener{

	JButton okS;
	JButton closeS;
	String sID;
	String advisor;
	String major;
	String gPA;
	String fName;
	String lName;
	String mI;
	String age;
	JTextField sIDT;
	JTextField adviT;
	JTextField majorT;
	JTextField gPAT;
	public Student()
	{	
		fName="";
		lName="";
		mI="";
		age="";
		sID="";
		advisor="";
		major="";
		gPA="";
		setLayout(new GridLayout(5, 4, 5, 5));
		JLabel sIDL= new JLabel("Student ID: ");
		sIDT= new JTextField(16);
		JLabel adviL= new JLabel("Advisor: ");
		adviT= new JTextField(1);
		JLabel majorL= new JLabel("Major: ");
		majorT= new JTextField(4);
		JLabel gPAL= new JLabel("GPA: ");
		gPAT= new JTextField(4);
		okS=new JButton("OK");
		closeS=new JButton("Close");
		okS.setActionCommand("OK");
		closeS.setActionCommand("CLOSE");
		okS.addActionListener(this);
		closeS.addActionListener(this);
		add(sIDL);
		add(sIDT);
		add(adviL);
		add(adviT);
		add(majorL);
		add(majorT);
		add(gPAL);
		add(gPAT);
		add(okS);
		add(closeS);
	}
	public void initialize()
	{
		this.setTitle("Student");
		remove(ok);
		remove(close);
		this.setSize(400,300);
		this.setLocationRelativeTo(null);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setVisible(true);
	}
	public void actionPerformed(ActionEvent event)
	{
		String command=event.getActionCommand();
		if(command=="OK")
		{
			sID=sIDT.toString();
			advisor=adviT.toString();
			major=majorT.toString();
			gPA=gPAT.toString();
			fName=super.getFName();
			lName=super.getFName();
			mI=super.getMI();
			age=super.getAge();
		}
		else if(command=="CLOSE")
		{
			dispose();
		}
	}
	public String getsID()
	{
		return sID;
	}
	public String getAdvisor()
	{
		return advisor;
	}
	public String getMajor()
	{
		return major;
	}
	public String getGPA()
	{
		return gPA;
	}
	public String getFNameT()
	{
		return fName;
	}
	public String getLNameT()
	{
		return lName;
	}
	public String getMIT()
	{
		return mI;
	}
	public String getAgeT()
	{
		return age;
	}
	public String toString()
	{
		return getFNameT() + " " + getLNameT() + " " + getMIT() + " " + getAgeT() +"\n"+getsID()+ " " + getAdvisor()+ " "+getMajor()+ " "+ getGPA();
	}
}
